#ifndef ECG_H
#define ECG_H

#include <QDateTime>
#include <QObject>

class Ecg : public QObject {
    Q_OBJECT
public:
    // 删除拷贝构造函数和赋值运算符，防止拷贝实例
    Ecg(const Ecg&) = delete;
    Ecg& operator=(const Ecg&) = delete;

    static Ecg& getInstance();

    int sampleRate() const;
    void setSampleRate(int newSampleRate);

    int duration() const;
    void setDuration(int newDuration);

    int startTimeStamp() const;
    void setStartTimeStamp(int newStartTimeStamp);

    Q_INVOKABLE int load();

    int adcZero() const;
    void setAdcZero(int newAdcZero);

    float adcGain() const;
    void setAdcGain(float newAdcGain);

private:
    explicit Ecg(QObject* parent = nullptr);

    int m_sampleRate = 200;
    int m_duration;
    int m_startTimeStamp = 0; //开始时间戳
    int m_adcZero = 0;
    float m_adcGain = 1;

    Q_PROPERTY(int sampleRate READ sampleRate WRITE setSampleRate NOTIFY sampleRateChanged FINAL)

    Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged FINAL)

    Q_PROPERTY(int startTimeStamp READ startTimeStamp WRITE setStartTimeStamp NOTIFY startTimeStampChanged FINAL)

    Q_PROPERTY(int adcZero READ adcZero WRITE setAdcZero NOTIFY adcZeroChanged FINAL)

    Q_PROPERTY(int adcGain READ adcGain WRITE setAdcGain NOTIFY adcGainChanged FINAL)

signals:
    void sampleRateChanged();
    void durationChanged();
    void startTimeStampChanged();
    void adcZeroChanged();
    void adcGainChanged();
};

#endif // ECG_H
